﻿// ================================================
// THumData.cs, 人物数据结构体
// Copyright (C) 2012 Daomi
// ================================================
using System;
using System.IO;
using System.Runtime.InteropServices;

namespace SystemModule
{
    /// <summary>
    /// 人物数据结构体 
    /// Size = 4487 
    /// </summary>
    public class THumData
    {
        #region Filed
        /// <summary>
        /// 玩家名称
        /// </summary>
        public string sChrName;//14
        /// <summary>
        /// 地图名称
        /// </summary>
        public string sCurMap;//16
        /// <summary>
        /// X坐标
        /// </summary>
        public ushort wCurX;
        /// <summary>
        /// Y坐标
        /// </summary>
        public ushort wCurY;
        /// <summary>
        /// 方向
        /// </summary>
        public byte btDir;
        /// <summary>
        /// 头发
        /// </summary>
        public byte btHair;
        /// <summary>
        /// 性别
        /// </summary>
        public byte btSex;
        /// <summary>
        /// 职业 0-战 1-法 2-道
        /// </summary>
        public byte btJob;
        /// <summary>
        /// 金币数
        /// </summary>
        public int nGold;
        /// <summary>
        /// 人物其它属性 Size 60
        /// </summary>
        public TOAbility Abil;
        /// <summary>
        /// 人物状态属性值，一般是持续多少秒
        /// </summary>
        public ushort[] wStatusTimeArr;
        /// <summary>
        /// 家
        /// </summary>
        public string sHomeMap;
        /// <summary>
        /// Home X
        /// </summary>
        public ushort wHomeX;
        /// <summary>
        /// Home Y
        /// </summary>
        public ushort wHomeY;
        /// <summary>
        /// 别名(配偶)
        /// </summary>
        public string sDearName;
        /// <summary>
        /// 师傅名字
        /// </summary>
        public string sMasterName;
        /// <summary>
        /// 是否有徒弟
        /// </summary>
        public bool boMaster;
        /// <summary>
        /// 声望点
        /// </summary>
        public int btCreditPoint;
        /// <summary>
        /// 是否结婚
        /// </summary>
        public byte btDivorce;
        /// <summary>
        /// 结婚次数
        /// </summary>
        public byte btMarryCount;
        /// <summary>
        /// 仓库密码
        /// </summary>
        public string sStoragePwd;
        /// <summary>
        /// 转生等级
        /// </summary>
        public byte btReLevel;
        /// <summary>
        /// 0-是否开通元宝寄售(1-开通) 1-是否寄存英雄(1-存有英雄) 2-饮酒时酒的品质
        /// </summary>
        public byte[] btUnKnow2;//3
        /// <summary>
        /// 人物额外属性点 Size 24
        /// </summary>
        public TNakedAbility BonusAbil;
        /// <summary>
        /// 奖励点
        /// </summary>
        public int nBonusPoint;
        /// <summary>
        /// 游戏币
        /// </summary>
        public int nGameGold;
        /// <summary>
        /// 金刚石
        /// </summary>
        public int nGameDiaMond;
        /// <summary>
        /// 灵符
        /// </summary>
        public int nGameGird;
        /// <summary>
        /// 声望
        /// </summary>
        public int nGamePoint;
        /// <summary>
        /// 荣誉
        /// </summary>
        public byte btGameGlory;
        /// <summary>
        /// 充值点
        /// </summary>
        public int nPayMentPoint;
        /// <summary>
        /// 英雄的忠诚度
        /// </summary>
        public int nLoyal;
        /// <summary>
        /// PK点数
        /// </summary>
        public int nPKPOINT;
        /// <summary>
        /// 允许组队
        /// </summary>
        public byte btAllowGroup;
        public byte btF9;
        /// <summary>
        /// 攻击模式
        /// </summary>
        public byte btAttatckMode;
        /// <summary>
        /// 增加健康数
        /// </summary>
        public byte btIncHealth;
        /// <summary>
        /// 增加攻击点
        /// </summary>
        public byte btIncSpell;
        /// <summary>
        /// 增加治愈点
        /// </summary>
        public byte btIncHealing;
        /// <summary>
        /// 在行会占争地图中死亡次数
        /// </summary>
        public byte btFightZoneDieCount;
        /// <summary>
        /// 登录帐号
        /// </summary>
        public string sAccount;
        /// <summary>
        /// 英雄类型 0-白日门英雄 1-卧龙英雄
        /// </summary>
        public byte btEF;
        /// <summary>
        /// 是否锁定登陆
        /// </summary>
        public bool boLockLogon;
        /// <summary>
        /// 贡献值
        /// </summary>
        public ushort wContribution;
        /// <summary>
        /// 饥饿状态
        /// </summary>
        public int nHungerStatus;
        /// <summary>
        /// 是否允许行会合一
        /// </summary>
        public bool boAllowGuildReCall;
        /// <summary>
        /// 队传送时间
        /// </summary>
        public ushort wGroupRcallTime;
        /// <summary>
        /// 幸运度
        /// </summary>
        public double dBodyLuck;
        /// <summary>
        /// 是否允许天地合一
        /// </summary>
        public bool boAllowGroupReCall;
        /// <summary>
        /// 经验倍数
        /// </summary>
        public int nEXPRATE;
        /// <summary>
        /// 经验倍数时间
        /// </summary>
        public int nExpTime;
        /// <summary>
        /// 退出状态 1为死亡退出
        /// </summary>
        public byte btLastOutStatus;    
        /// <summary>
        /// 出师徒弟数
        /// </summary>
        public ushort wMasterCount;
        /// <summary>
        /// 是否有白日门英雄
        /// </summary>
        public bool boHasHero;
        /// <summary>
        /// 是否是英雄
        /// </summary>
        public bool boIsHero;
        /// <summary>
        /// 状态
        /// </summary>
        public byte btStatus;
        /// <summary>
        /// 英雄名称
        /// </summary>
        public string sHeroChrName;
        /// <summary>
        /// 0-3酿酒使用 4-饮酒时的度数 5-魔法盾等级 6-是否学过内功 7-内功等级
        /// </summary>
        public byte[] UnKnow;
        /// <summary>
        /// 脚本变量
        /// </summary>
        public byte[] QuestFlag;
        /// <summary>
        /// 身上物品
        /// 9格装备 衣服  武器  蜡烛 头盔 项链 手镯 手镯 戒指 戒指
        /// </summary>
        public TUserItem[] HumItems;
        /// <summary>
        /// 包裹物品
        /// </summary>
        public TUserItem[] BagItems;
        /// <summary>
        /// 魔法
        /// </summary>
        public THumMagic[] HumMagics;
        /// <summary>
        /// 仓库物品
        /// </summary>
        public TUserItem[] StorageItems;
        /// <summary>
        /// 新增4格 护身符 腰带 鞋子 宝石
        /// </summary>
        public TUserItem[] HumAddItems;
        /// <summary>
        /// 累计经验
        /// </summary>
        public int n_WinExp;
        /// <summary>
        /// 聚灵珠聚集时间
        /// </summary>
        public int n_UsesItemTick;
        /// <summary>
        /// 酿酒的时间,即还有多长时间可以取回酒
        /// </summary>
        public int nReserved;
        /// <summary>
        /// 当前药力值
        /// </summary>
        public int nReserved1;
        /// <summary>
        /// 药力值上限
        /// </summary>
        public int nReserved2;
        /// <summary>
        /// 使用药酒时间,计算长时间没使用药酒
        /// </summary>
        public int nReserved3;
        /// <summary>
        /// 当前酒量值
        /// </summary>
        public ushort n_Reserved;
        /// <summary>
        /// 酒量上限
        /// </summary>
        public ushort n_Reserved1;
        /// <summary>
        /// 当前醉酒度
        /// </summary>
        public ushort n_Reserved2;
        /// <summary>
        /// 药力值等级
        /// </summary>
        public ushort n_Reserved3;
        /// <summary>
        /// 是否请过酒 T-请过酒
        /// </summary>
        public bool boReserved;
        /// <summary>
        /// 是否有卧龙英雄
        /// </summary>
        public bool boReserved1;
        /// <summary>
        /// 是否酿酒 T-正在酿酒
        /// </summary>
        public bool boReserved2;
        /// <summary>
        /// 人是否喝酒醉了
        /// </summary>
        public bool boReserved3;
        /// <summary>
        /// 人物领取行会酒泉日期
        /// </summary>
        public int m_GiveDate;
        /// <summary>
        /// 酒气护体当前经验
        /// </summary>
        public int Exp68;
        /// <summary>
        /// 酒气护体升级经验
        /// </summary>
        public int MaxExp68;
        /// <summary>
        /// 内功当前经验
        /// </summary>
        public int nExpSkill69;
        /// <summary>
        /// 内功技能
        /// </summary>
        public THumMagic[] HumNGMagics;
        /// <summary>
        /// 人物经络
        /// </summary>
        public TBatterPulse[] HumPulses;
        /// <summary>
        /// 连击循序
        /// </summary>
        public THumMagic[] HumBatterMagics;
        public ushort[] BatterMagicOrder;
        public bool m_boIsOpenPuls;// (英雄) 是否打开经络
        public uint m_nPulseExp;// (英雄) 经络经验
        public string sMentHeroChrName;// 副将英雄名称 14
        public int nMentHeroIncExp;// 副将英雄累计经验
        public byte m_btFHeroJob;
        public byte m_btFHeroType;
        public byte m_nReserved5;// 保留
        public ushort m_nReserved6;// 保留
        public int m_nReserved7;// 保留
        public int m_nReserved8;
        #endregion

        public THumData()
        {

        }

        public THumData(byte[] buff)
        {
            this.sChrName = System.Text.Encoding.Default.GetString(buff, 0, 14).Replace("\0", "");//+14
            this.sCurMap = System.Text.Encoding.Default.GetString(buff, 15, 16).Replace("\0", "");//+16
            this.wCurX = BitConverter.ToUInt16(buff, 31);//+2
            this.wCurY = BitConverter.ToUInt16(buff, 33);//+2
            this.btDir = buff[35];//+1
            this.btHair = buff[36];//+1
            this.btSex = buff[37];//+1
            this.btJob = buff[38];//+1
            this.nGold = BitConverter.ToInt32(buff, 39);
            var abilBuff = new byte[60];
            Array.Copy(buff, 43, abilBuff, 0, abilBuff.Length);
            this.Abil = new TOAbility(abilBuff);//+60
            this.wStatusTimeArr = new ushort[12];
            Array.Copy(buff, 104, wStatusTimeArr, 0, wStatusTimeArr.Length);//+24
            this.sHomeMap = System.Text.Encoding.Default.GetString(buff, 128, 16).Replace("\0", "");
            this.wHomeX = BitConverter.ToUInt16(buff, 144);
            this.wHomeY = BitConverter.ToUInt16(buff, 146);
            this.sDearName = System.Text.Encoding.Default.GetString(buff, 148, 14).Replace("\0", "");
            this.sMasterName = System.Text.Encoding.Default.GetString(buff, 162, 14).Replace("\0", "");
            this.boMaster = BitConverter.ToBoolean(buff, 177);//+1
            this.btCreditPoint = BitConverter.ToUInt16(buff, 178);//+2
            this.btDivorce = buff[180];//+1
            this.btMarryCount = buff[181];//+1
            this.sStoragePwd = System.Text.Encoding.Default.GetString(buff, 182, 7).Replace("\0", "");//7
            this.btReLevel = buff[190];//+1
            this.btUnKnow2 = new byte[3];
            Array.Copy(buff, 191, btUnKnow2, 0, btUnKnow2.Length);//3

            var bonusAbilBuff = new byte[24];
            Array.Copy(buff, 195, bonusAbilBuff, 0, bonusAbilBuff.Length);//24
            this.BonusAbil = new TNakedAbility(bonusAbilBuff);//215

            this.nBonusPoint = BitConverter.ToInt32(buff, 220);//+4
            this.nGameGold = BitConverter.ToInt32(buff, 225);//+4
            this.nGameDiaMond = BitConverter.ToInt32(buff, 230);//+4
            this.nGameGird = BitConverter.ToInt32(buff, 236);//+4
            this.nGamePoint = BitConverter.ToInt32(buff, 241);//+4
            this.btGameGlory = buff[242];//+1
            this.nPayMentPoint = BitConverter.ToInt32(buff, 243);//+4
            this.nLoyal = BitConverter.ToInt32(buff, 247);//+4
            this.nPKPOINT = BitConverter.ToInt32(buff, 251);//+4
            this.btAllowGroup = buff[255];//+1
            this.btF9 = buff[256];//+1
            this.btAttatckMode = buff[257];//+1
            this.btIncHealth = buff[258];//+1
            this.btIncSpell = buff[259];//+1
            this.btIncHealing = buff[260];//+1
            this.btFightZoneDieCount = buff[261];//+1
            this.sAccount = System.Text.Encoding.Default.GetString(buff, 262, 10).Replace("\0", "");//+10
            this.btEF = buff[273];//+1
            this.boLockLogon = BitConverter.ToBoolean(buff, 274);//+1
            this.wContribution = BitConverter.ToUInt16(buff, 275);//+2
            this.nHungerStatus = BitConverter.ToInt32(buff, 279);//+4
            this.boAllowGuildReCall = BitConverter.ToBoolean(buff, 280);//+1
            this.wGroupRcallTime = BitConverter.ToUInt16(buff, 281);//+2
            this.dBodyLuck = BitConverter.ToDouble(buff, 283);//+8
            this.boAllowGroupReCall = BitConverter.ToBoolean(buff, 291);//+1
            this.nEXPRATE = BitConverter.ToUInt16(buff, 292);//+2
            this.nExpTime = BitConverter.ToUInt16(buff, 294);//+2
            this.btLastOutStatus = buff[295];//+1
            this.wMasterCount = BitConverter.ToUInt16(buff, 296);//+2
            this.boHasHero = BitConverter.ToBoolean(buff, 299);//+1
            this.boIsHero = BitConverter.ToBoolean(buff, 300);//+1
            this.btStatus = buff[301];//+1
            this.sHeroChrName = System.Text.Encoding.Default.GetString(buff, 302, 14).Replace("\0", "");//+13
            this.UnKnow = new byte[30];//+30
            Array.Copy(buff, 317, UnKnow, 0, UnKnow.Length);
            this.QuestFlag = new byte[128];//+128
            Array.Copy(buff, 351, QuestFlag, 0, QuestFlag.Length);

            this.HumItems = new TUserItem[9];
            var humItemBuff = new byte[288];
            Array.Copy(buff, 479, humItemBuff, 0, humItemBuff.Length);

            for (int i = 0; i < HumItems.Length; i++)
            {
                var itemBuff = new byte[32];
                Array.Copy(humItemBuff, i * 32, itemBuff, 0, itemBuff.Length);
                HumItems[i] = new TUserItem(itemBuff);
            }

            this.BagItems = new TUserItem[46];
            var bagItemBuff = new byte[1472];
            Array.Copy(buff, 767, bagItemBuff, 0, bagItemBuff.Length);

            for (int i = 0; i < BagItems.Length; i++)
            {
                var itemBuff = new byte[32];
                Array.Copy(bagItemBuff, i * 32, itemBuff, 0, itemBuff.Length);
                BagItems[i] = new TUserItem(itemBuff);
            }

            this.HumMagics = new THumMagic[30];//+240
            var hubMagicBuff = new byte[240];
            Array.Copy(buff, 2239, hubMagicBuff, 0, hubMagicBuff.Length);
            for (int i = 0; i < HumMagics.Length; i++)
            {
                var itemBuff = new byte[8];
                Array.Copy(hubMagicBuff, i * 8, itemBuff, 0, itemBuff.Length);
                HumMagics[i] = new THumMagic(itemBuff);
            }

            this.StorageItems = new TUserItem[46];//+1472
            var storageBuff = new byte[1472];
            Array.Copy(buff, 2475, storageBuff, 0, storageBuff.Length);
            for (int i = 0; i < StorageItems.Length; i++)
            {
                var itemBuff = new byte[32];
                Array.Copy(storageBuff, i * 32, itemBuff, 0, itemBuff.Length);
                StorageItems[i] = new TUserItem(itemBuff);
            }

            this.HumAddItems = new TUserItem[5];//+160
            var humaddBuff = new byte[160];
            Array.Copy(buff, 3948, humaddBuff, 0, humaddBuff.Length);
            for (int i = 0; i < HumAddItems.Length; i++)
            {
                var itemBuff = new byte[32];
                Array.Copy(humaddBuff, i * 32, itemBuff, 0, itemBuff.Length);
                HumAddItems[i] = new TUserItem(itemBuff);
            }

            //+24
            this.n_WinExp = BitConverter.ToInt32(buff, 4109);//+4
            this.n_UsesItemTick = BitConverter.ToInt32(buff, 4114);//+4
            this.nReserved = BitConverter.ToInt32(buff, 4119);//+4
            this.nReserved1 = BitConverter.ToInt32(buff, 4123);//+4
            this.nReserved2 = BitConverter.ToInt32(buff, 4127);//+4
            this.nReserved3 = BitConverter.ToInt32(buff, 4131);//+4
            this.n_Reserved = BitConverter.ToUInt16(buff, 4135);//+2
            this.n_Reserved1 = BitConverter.ToUInt16(buff, 4137);//+2
            this.n_Reserved2 = BitConverter.ToUInt16(buff, 4139);//+2
            this.n_Reserved3 = BitConverter.ToUInt16(buff, 4141);//+2
            this.boReserved = BitConverter.ToBoolean(buff, 4128);//+1
            this.boReserved1 = BitConverter.ToBoolean(buff, 4129);//+1
            this.boReserved2 = BitConverter.ToBoolean(buff, 4130);//+1
            this.boReserved3 = BitConverter.ToBoolean(buff, 4131);//+1
            this.m_GiveDate = BitConverter.ToInt32(buff, 4132);//+4
            this.Exp68 = BitConverter.ToInt32(buff, 4137);//+4
            this.MaxExp68 = BitConverter.ToInt32(buff, 4142);//+4
            this.nExpSkill69 = BitConverter.ToInt32(buff, 4146);//+4

            this.HumNGMagics = new THumMagic[30];//+240
            var hunngBuff = new byte[240];
            Array.Copy(buff, 4143, hunngBuff, 0, hunngBuff.Length);
            for (int i = 0; i < HumNGMagics.Length; i++)
            {
                var itemBuff = new byte[8];
                Array.Copy(hunngBuff, i * 8, itemBuff, 0, itemBuff.Length);
                HumNGMagics[i] = new THumMagic(itemBuff);
            }

            this.HumPulses = new TBatterPulse[4];//+8
            var pulsesBuff = new byte[8];
            Array.Copy(buff, 4384, pulsesBuff, 0, pulsesBuff.Length);
            for (int i = 0; i < HumPulses.Length; i++)
            {
                var itemBuff = new byte[2];
                Array.Copy(hunngBuff, i * 2, itemBuff, 0, itemBuff.Length);
                HumPulses[i] = new TBatterPulse(itemBuff);
            }

            this.HumBatterMagics = new THumMagic[4];//+32
            var batterBuff = new byte[32];
            Array.Copy(buff, 4393, batterBuff, 0, batterBuff.Length);
            for (int i = 0; i < HumPulses.Length; i++)
            {
                var itemBuff = new byte[8];
                Array.Copy(batterBuff, i * 8, itemBuff, 0, itemBuff.Length);
                HumBatterMagics[i] = new THumMagic(itemBuff);
            }

            this.BatterMagicOrder = new ushort[3];
            Array.Copy(buff, 4426, BatterMagicOrder, 0, BatterMagicOrder.Length);

            this.m_boIsOpenPuls = BitConverter.ToBoolean(buff, 4433);//+1
            this.m_nPulseExp = BitConverter.ToUInt32(buff, 4434);//+4
            this.sMentHeroChrName = System.Text.Encoding.Default.GetString(buff, 4439, 14).Replace("\0", "");//+14
            this.nMentHeroIncExp = BitConverter.ToInt32(buff, 4454);//+4
            this.m_btFHeroJob = buff[4455];//+1
            this.m_btFHeroType = buff[4456];//+1
            this.m_nReserved5 = buff[4457];//+1
            this.m_nReserved6 = BitConverter.ToUInt16(buff, 4458);//+2
            this.m_nReserved7 = BitConverter.ToInt32(buff, 4460);//+4
            this.m_nReserved8 = BitConverter.ToInt32(buff, 4464);//+4
        }

        public byte[] ToByte()
        {
            using (var memoryStream = new MemoryStream())
            {
                var backingStream = new BinaryWriter(memoryStream);
                backingStream.Write(sChrName.ToByte(15));
                backingStream.Write(sCurMap.ToByte(17));
                backingStream.Write(wCurX);
                backingStream.Write(wCurY);
                backingStream.Write(btDir);
                backingStream.Write(btHair);
                backingStream.Write(btSex);
                backingStream.Write(btJob);
                backingStream.Write(nGold);
                backingStream.Write(Abil.ToByte());
                for (int i = 0; i < wStatusTimeArr.Length; i++)
                {
                    backingStream.Write(wStatusTimeArr[i]);
                }
                backingStream.Write(sHomeMap.ToByte(17));
                backingStream.Write(wHomeX);
                backingStream.Write(wHomeY);
                backingStream.Write(sDearName.ToByte(15));
                backingStream.Write(sMasterName.ToByte(15));
                backingStream.Write(boMaster);
                backingStream.Write(btCreditPoint);
                backingStream.Write(btDivorce);
                backingStream.Write(btMarryCount);
                backingStream.Write(sStoragePwd.ToByte(8));//8
                backingStream.Write(btReLevel);
                backingStream.Write(btUnKnow2);
                backingStream.Write(BonusAbil.ToByte());//24
                backingStream.Write(nBonusPoint);
                backingStream.Write(nGameGold);
                backingStream.Write(nGameDiaMond);
                backingStream.Write(nGameGird);
                backingStream.Write(nGamePoint);
                backingStream.Write(btGameGlory);
                backingStream.Write(nPayMentPoint);
                backingStream.Write(nLoyal);
                backingStream.Write(nPKPOINT);
                backingStream.Write(btAllowGroup);
                backingStream.Write(btF9);
                backingStream.Write(btAttatckMode);
                backingStream.Write(btIncHealth);
                backingStream.Write(btIncSpell);
                backingStream.Write(btIncHealing);
                backingStream.Write(btFightZoneDieCount);
                backingStream.Write(sAccount.ToByte(11));
                backingStream.Write(btEF);
                backingStream.Write(boLockLogon);
                backingStream.Write(wContribution);
                backingStream.Write(nHungerStatus);
                backingStream.Write(boAllowGuildReCall);
                backingStream.Write(wGroupRcallTime);
                backingStream.Write(dBodyLuck);
                backingStream.Write(boAllowGroupReCall);
                backingStream.Write(nEXPRATE);
                backingStream.Write(nExpTime);
                backingStream.Write(btLastOutStatus);
                backingStream.Write(wMasterCount);
                backingStream.Write(boHasHero);
                backingStream.Write(boIsHero);
                backingStream.Write(btStatus);
                backingStream.Write(sHeroChrName.ToByte(15));
                backingStream.Write(UnKnow);
                backingStream.Write(QuestFlag);
                for (int i = 0; i < HumItems.Length; i++)
                {
                    backingStream.Write(this.HumItems[i].ToByte());
                }
                for (int i = 0; i < BagItems.Length; i++)
                {
                    backingStream.Write(BagItems[i].ToByte());
                }
                for (int i = 0; i < HumMagics.Length; i++)
                {
                    backingStream.Write(HumMagics[i].ToByte());
                }
                for (int i = 0; i < StorageItems.Length; i++)
                {
                    backingStream.Write(StorageItems[i].ToByte());
                }
                for (int i = 0; i < HumAddItems.Length; i++)
                {
                    backingStream.Write(HumAddItems[i].ToByte());
                }
                backingStream.Write(n_WinExp);
                backingStream.Write(n_UsesItemTick);
                backingStream.Write(nReserved);
                backingStream.Write(nReserved1);
                backingStream.Write(nReserved2);
                backingStream.Write(nReserved3);
                backingStream.Write(n_Reserved);
                backingStream.Write(n_Reserved1);
                backingStream.Write(n_Reserved2);
                backingStream.Write(n_Reserved3);
                backingStream.Write(boReserved);
                backingStream.Write(boReserved1);
                backingStream.Write(boReserved2);
                backingStream.Write(boReserved3);
                backingStream.Write(m_GiveDate);
                backingStream.Write(Exp68);
                backingStream.Write(MaxExp68);
                backingStream.Write(nExpSkill69);

                for (int i = 0; i < HumNGMagics.Length; i++)
                {
                    backingStream.Write(HumNGMagics[i].ToByte());
                }
                for (int i = 0; i < HumPulses.Length; i++)
                {
                    backingStream.Write(HumPulses[i].ToByte());
                }
                for (int i = 0; i < HumBatterMagics.Length; i++)
                {
                    backingStream.Write(HumBatterMagics[i].ToByte());
                }
                for (int i = 0; i < BatterMagicOrder.Length; i++)
                {
                    backingStream.Write(BatterMagicOrder[i]);
                }

                backingStream.Write(m_boIsOpenPuls);
                backingStream.Write(m_nPulseExp);
                backingStream.Write(sMentHeroChrName.ToByte(15));
                backingStream.Write(nMentHeroIncExp);
                backingStream.Write(m_btFHeroJob);
                backingStream.Write(m_btFHeroType);
                backingStream.Write(m_nReserved5);
                backingStream.Write(m_nReserved6);
                backingStream.Write(m_nReserved7);
                backingStream.Write(m_nReserved8);
                var stream = backingStream.BaseStream as MemoryStream;
                return stream.ToArray();
            }
        }
    }
}